home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 284 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: prefix vs. postfix
  5. Date: Thu, 04 Jan 1996 01:32:21 GMT
  6. Organization: Netcom
  7. Message-ID: <30eb2dec.9255744@nntp.ix.netcom.com>
  8. References: <4c1089$gro@nntpd2.cxo.dec.com> <tcpnntpd.15.12.30.11.27.18.2781597121.305087@the-fix.sos.on.ca> <30DEC199514333959@erich.triumf.ca> <4cf35v$7il@head.globalcom.net>
  9. NNTP-Posting-Host: ix-dc11-10.ix.netcom.com
  10. X-NETCOM-Date: Wed Jan 03  5:30:45 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. scicom@globalcom.net (stephen j beaver) wrote:
  14.  
  15. |><SNIP>
  16. |>
  17. |>>The two operators _never_ do the same thing.  However, if you just
  18. want the
  19. |>>side effect of the increment, but the value returned by i++ or ++i
  20. is not used,
  21. |>>(as in for(i = 0; i < 10; i++) ) it doesn't matter which is used.
  22. |>
  23. |>I thought that:
  24. |>
  25. |>for(i=0;i<10;i++)
  26. |>   {
  27. |>   loopbody(i):
  28. |>   }
  29. |>
  30. |>Increments i after the loop so that the first value passed to
  31. loopbody() is zero, whereas:
  32. |>
  33. |>for(i=0;i<10;++i)
  34. |>   {
  35. |>  loopbody();
  36. |>   }
  37. |>
  38. |>increments i before the loop body so that the first value passedtp
  39. loopbody() is 1 in this case.
  40. |>
  41. |>No?
  42.  
  43. No.  Both do the incrementation at the end of the loop.  The
  44. reinitialization expression (the third in the for) is always done at
  45. the end of the loop.
  46.  
  47. Michael M Rubenstein
  48.